package com.ssy.lingxi.product.entity.platform;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 属性值实体类--平台后台
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/6/23
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "product_attribute_value", indexes = {@Index(name = "product_attribute_value_value_idx", columnList = "value"),
        @Index(name = "product_attribute_value_is_enable_idx", columnList = "isEnable")})
public class AttributeValue implements Serializable {
    private static final long serialVersionUID = 6759973368634280456L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="attribute_value_seq")
    @SequenceGenerator(sequenceName="product_attribute_value_seq", name="attribute_value_seq",allocationSize = 1)
    private Long id;

    /**
     * 属性值
     */
    @Column(columnDefinition = "varchar(24)", nullable = false)
    private String value;

    /**
     * 属性值图片url路径
     */
    @Column(columnDefinition = "varchar(250)")
    private String imageUrl;

    /**
     * 属性值是否有效
     */
    @Column(columnDefinition = "boolean", nullable = false)
    private Boolean isEnable = true;

    /**
     * 属性实体
     */
    @JsonIgnore
    @ManyToOne(cascade = {CascadeType.PERSIST})
    @JoinColumn(name="attributeId",referencedColumnName = "id")
    private Attribute attribute;
}
